function P = PKH_prices_v4(CAPH,MU,rho,T)

%%%%%%%%%%%%%%%%%%%
Nstates = size(MU(:,1),1);
P=zeros(Nstates-1,T);
Pt = MU(1:end-1,:,T);
P(:,T)=Pt;

for k = 1:T-1
    t = T-k;
    CAPt = CAPH(:,:,t);
    % conditional on surviving
    CAPt = CAPt./(1-repmat(CAPt(:,end),1,Nstates));
    CAPt = CAPt(1:end-1,1:end-1);
    Pf = P(:,t+1);
    EP = CAPt*Pf;
    P(:,t) =MU(1:end-1,t)+rho*(EP-ones(Nstates-1,1)*P(1,t+1)).*(1-CAPH(1:end-1,end,t));    
end

end
 

    
    
    
    
    
    